#include "borderless.h"
#include "ui_borderless.h"
#include <QDebug>

Borderless::Borderless(QWidget *parent)
	: QWidget(parent)
	, ui(new Ui::Borderless)
{
	ui->setupUi(this);
	this->setWindowFlags(Qt::FramelessWindowHint);
	ui->widget->setPalette(QPalette(Qt::white));//设置窗口为白色背景
	ui->widget->setAutoFillBackground(true);
}

Borderless::~Borderless()
{
	delete ui;
}
void Borderless::mouseMoveEvent(QMouseEvent *event)
{
	QWidget::mouseMoveEvent(event);
	//z值固定不变
	QPoint x = event->globalPos()-z;
	this->move(x);
}
void Borderless::mousePressEvent(QMouseEvent *event)
{
	QWidget::mousePressEvent(event);
	z = event->pos();
	//计算三个位置
	qDebug() <<"geometry位置 : "<<this->geometry().topLeft()<<"global位置 : "<<event->globalPos()<<"pos位置 : "<<z;
}
void Borderless::mouseReleaseEvent(QMouseEvent *event)
{
	QWidget::mouseReleaseEvent(event);
}

void Borderless::on_pushButton_clicked()
{
	this->close();
}

void Borderless::on_pushButton_3_clicked()
{
	this->showMinimized();
}

void Borderless::on_pushButton_2_clicked()
{
	if(ui->pushButton_2->text() == "还原")
	{
		ui->pushButton_2->setText("最大化");
		this->showNormal();
	}
	else
	{
		ui->pushButton_2->setText("还原");
		this->showMaximized();
	}
}
